package com.xuan.singleton.lazy;

public class Singleton2 {
    private Singleton2() {}

    private static Singleton2 instance;

    /**
     * 懒汉式单例
     * 线程不安全
     * 第一次访问时创建实例
     * @return
     */
    public static Singleton2 getInstance() {
        if (instance == null) {
            instance = new Singleton2();
        }
        return instance;
    }
}
